﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="ettevotja_muudatus_kandevaline", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(EttevotjaMuudatusKandevaline))]
    public class EttevotjaMuudatusKandevalineSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IEttevotjaMuudatusKandevaline clazz;
        
        public EttevotjaMuudatusKandevalineSerializer(IEttevotjaMuudatusKandevaline clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.KandevalineTyyp!=null) {
                Writer.WriteStartElement("kandevaline_tyyp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KandevalineTyyp))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.EttevotjaId!=null) {
                Writer.WriteStartElement("ettevotja_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EttevotjaId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.EttevotjaAriregistriKood!=null) {
                Writer.WriteStartElement("ettevotja_ariregistri_kood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.EttevotjaAriregistriKood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.EttevotjaArinimi!=null) {
                Writer.WriteStartElement("ettevotja_arinimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EttevotjaArinimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.EttevotjaOiguslikVorm!=null) {
                Writer.WriteStartElement("ettevotja_oiguslik_vorm");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EttevotjaOiguslikVorm))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KirjeId!=null) {
                Writer.WriteStartElement("kirje_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KirjeId))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="kandevaline_tyyp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_kandevaline>kandevaline_tyyp");
                }
                clazz.KandevalineTyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kandevaline_tyyp")).Value;
            }
            if (Reader.LocalName=="ettevotja_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_kandevaline>ettevotja_id");
                }
                clazz.EttevotjaId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ettevotja_id")).Value;
            }
            if (Reader.LocalName=="ettevotja_ariregistri_kood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_kandevaline>ettevotja_ariregistri_kood");
                }
                clazz.EttevotjaAriregistriKood = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("ettevotja_ariregistri_kood")).Value;
            }
            if (Reader.LocalName=="ettevotja_arinimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_kandevaline>ettevotja_arinimi");
                }
                clazz.EttevotjaArinimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ettevotja_arinimi")).Value;
            }
            if (Reader.LocalName=="ettevotja_oiguslik_vorm") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_kandevaline>ettevotja_oiguslik_vorm");
                }
                clazz.EttevotjaOiguslikVorm = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ettevotja_oiguslik_vorm")).Value;
            }
            if (Reader.LocalName=="kirje_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ettevotja_muudatus_kandevaline>kirje_id");
                }
                clazz.KirjeId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kirje_id")).Value;
            }
        }
    }
}
